package com.tm.dk.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tm.dk.service.RealtimeService;
import com.tm.entity.dto.CompanyDto;
import com.tm.exception.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("realtime")
public class RealtimeController {
    @Autowired
    private RealtimeService realtimeService;

    //分页查询
    @PostMapping("query")
    public Result query(@RequestBody CompanyDto companyDto){
        Page<CompanyDto> list = realtimeService.query(companyDto);
        return Result.success(list);
    }

    //删除
    @PostMapping("delete")
    public Result delete(@RequestBody CompanyDto companyDto){
        boolean b = realtimeService.removeById(companyDto.getId());
        return Result.success("删除成功啦");
    }

    //新增
    @PostMapping("add")
    public Result add(@RequestBody CompanyDto companyDto){
        return realtimeService.add(companyDto);
    }

    //回显
    @PostMapping("getById")
    public Result getById(@RequestBody CompanyDto companyDto){
        CompanyDto byId = realtimeService.getById(companyDto.getId());
        return Result.success(byId);
    }

    //修改
    @PostMapping("update")
    public Result update(@RequestBody CompanyDto companyDto){
        return realtimeService.update1(companyDto);
    }

}
